<?php
/** @var File $model */
/** @var TbActiveForm $form */
?>

<div class="row-fluid">
	<?php $form = $this->beginWidget('bootstrap.widgets.TbActiveForm', array(
		'id' => 'file-form',
		//'type' => 'horizontal',
	)); ?>
	<div class="<?php echo $isAjax ? "span12" : "span8" ?> media-fields" id="media-fields">
		<?php if (!$isAjax && $model->isImage()): ?>
			<div class="media-icon">
				<?php echo $model->getImage(File::IMAGE_ORIGIN); ?>
			</div>
		<?php endif; ?>

		<p class="help-block"><span class="required">*</span> 字段必填.</p>

		<?php if (!$isAjax): ?>
			<?php echo $form->errorSummary($model); ?>
		<?php endif; ?>

		<?php echo $form->textFieldRow($model, 'name', array('class' => 'span12', 'maxlength' => 64)); ?>

		<?php
		if ($model->isImage()) {
			echo $form->textFieldRow($model, 'alt', array('class' => 'span12', 'maxlength' => 128));
		}
		?>

		<?php echo $form->textareaRow($model, 'caption', array('class' => 'span12', 'rows' => 2)); ?>

		<?php echo $form->textareaRow($model, 'description', array('class' => 'span12', 'rows' => 4)); ?>
		<div class="form-actions">
			<?php $this->widget('bootstrap.widgets.TbButton', array(
				'buttonType' => 'submit',
				'type' => 'primary',
				'encodeLabel' => false,
				'label' => $model->isNewRecord ? '<i class="fa fa-plus"></i> 创建' : '<i class="fa fa-save"></i> 保存',
			)); ?>
		</div>

		<?php $this->endWidget(); ?>
	</div>
	<?php if (!$isAjax): ?>
		<div class="span4 media-info" id="media-info">
			<?php
			$this->beginWidget('bootstrap.widgets.TbBox', array('title' => '文件信息'));
			?>
			<p><span class="fa fa-calendar"></span> 上传于：<?php echo Yii::app()->format->datetime($model->create_time); ?>
			</p>

			<p>
				文件URL：
				<?php echo CHtml::textField('url', $model->getUrl(), array('readonly' => true, 'class' => 'input-block-level clone')); ?></p>

			<p>文件名：<strong><?php echo $model->filename ?></strong></p>

			<p>文件类型：<strong><?php echo strtoupper($model->getExt()) ?></strong></p>

			<p>文件大小：<strong><?php echo $model->getSize(); ?></strong></p>
			<?php if ($model->isImage() && isset($model->meta['sizes'][File::IMAGE_ORIGIN])) :
				$size = $model->meta['sizes'][File::IMAGE_ORIGIN];
				?>
				<p>文件尺寸：<strong><?php echo $size['width'] ?>&nbsp;&times;&nbsp;<?php echo $size['height']; ?></strong>
				</p>
			<?php endif; ?>
			<?php $this->endWidget(); ?>
		</div>
	<?php endif; ?>
</div>


